//
//  RestaurantPopView.m
//  ClassifyShop
//
//  Created by yuyao on 15/3/7.
//  Copyright (c) 2015年 yuyao. All rights reserved.
//

#import "RestaurantPopView.h"
#import "GUIDefine.h"
#import "CustomButtonsView.h"
@implementation RestaurantPopView
- (id)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
        UIView *middleView = [UIView new];
        [self addSubview:middleView];
        [middleView setBackgroundColor:[UIColor whiteColor]];
        
        [middleView setBackgroundColor:[[UIColor alloc] initWithPatternImage:[appDelegate scaleToSize:[UIImage imageNamed:@"1 大框.png"] size:CGSizeMake(300, 420)]]];

        [middleView setFrame:CGRectMake((frame.size.width-300)/2, (frame.size.height-420)/2, 300, 420)];
        
        UIImageView *image1 = [[UIImageView alloc] initWithFrame:CGRectMake(10, 20, 20, 20)];
        [image1 setImage:[UIImage imageNamed:@"3 商圈.png"]];
        [middleView addSubview:image1];
        
        UILabel *label1 = [[UILabel alloc] initWithFrame:CGRectMake(40, 15, 50, 30)];
        [label1 setText:@"商圈"];
        [label1 setFont:[UIFont fontWithName:@"Arial" size:12]];
        [middleView addSubview:label1];
        
        CustomButtonsView *shangquanView = [[CustomButtonsView alloc] initWithFrame:CGRectMake(0, 50, frame.size.width, 50) buttons:[NSArray arrayWithObjects:@"五华区",@"盘龙区",@"西山区",@"官渡区", nil]];
        [middleView addSubview:shangquanView];
        
        
        UIImageView *image2 = [[UIImageView alloc] initWithFrame:CGRectMake(10, 120, 20, 20)];
        [image2 setImage:[UIImage imageNamed:@"4 菜系.png"]];
        [middleView addSubview:image2];
        
        UILabel *label2 = [[UILabel alloc] initWithFrame:CGRectMake(40, 115, 50, 30)];
        [label2 setText:@"菜系"];
        [label2 setFont:[UIFont fontWithName:@"Arial" size:12]];
        [middleView addSubview:label2];
        
        
        CustomButtonsView *caixiView = [[CustomButtonsView alloc] initWithFrame:CGRectMake(0, 150, frame.size.width, 100) buttons:[NSArray arrayWithObjects:@"火锅",@"中餐",@"西餐",@"小吃",@"海鲜",@"自助餐",@"日韩料理",@"民族餐",@"东南亚菜", nil]];
        [middleView addSubview:caixiView];
        
        
        UIImageView *image3 = [[UIImageView alloc] initWithFrame:CGRectMake(10, 270, 20, 20)];
        [image3 setImage:[UIImage imageNamed:@"5 优选.png"]];
        [middleView addSubview:image3];
        
        UILabel *label3 = [[UILabel alloc] initWithFrame:CGRectMake(40, 265, 50, 30)];
        [label3 setText:@"优选"];
        [label3 setFont:[UIFont fontWithName:@"Arial" size:12]];
        [middleView addSubview:label3];
        
        CustomButtonsView *youxuanView = [[CustomButtonsView alloc] initWithFrame:CGRectMake(0, 300, frame.size.width, 50) buttons:[NSArray arrayWithObjects:@"离我最近",@"口味最佳",@"环境最佳", nil]];
        [middleView addSubview:youxuanView];
        
        
        UIButton *sureButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [sureButton setFrame:CGRectMake((middleView.frame.size.width-70)/2, middleView.frame.size.height-50, 120, 30)];
        [sureButton setTitle:@"确定" forState:UIControlStateNormal];
        [sureButton addTarget:self action:@selector(closeView) forControlEvents:UIControlEventTouchUpInside];
        [sureButton setBackgroundImage:[UIImage imageNamed:@"7 确定.png"] forState:UIControlStateNormal];
        [sureButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [sureButton.titleLabel setFont:[UIFont fontWithName:@"Arial" size:13]];
        [middleView addSubview:sureButton];
        
        [sureButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(middleView);
            make.bottom.equalTo(middleView.mas_bottom).with.offset(-20);
            make.size.mas_equalTo(CGSizeMake(120, 30));

        }];

        
    }
    return self;
}
- (void)closeView{
    [self removeFromSuperview];
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
